package com.sgb.kjwl.viewmodel.packers;


import com.sgb.kjwl.AppConstant;
import com.sgb.kjwl.repository.HomeRepertory;
import com.sgb.kjwl.view.ui.activity.packers.PackersPersonDetailActivity;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MLog;

/**
*@author pangyuheng
*@date 2019/7/9
*description:
*/
public class PackersPersonDetailModel extends BaseViewModel {
    private PackersPersonDetailActivity activity;
    private HomeRepertory repertory;


    public PackersPersonDetailModel(PackersPersonDetailActivity activity, HomeRepertory repertory) {
        this.activity = activity;
        this.repertory = repertory;
    }

    public void getCurrentUserInfo(String id) {
        DialogHelper.showProgressDialog(activity, null, "获取信息中...", 0, false, null).setCanceledOnTouchOutside(false);
        repertory.getPackersPersonDetailEntity(id)
                .subscribe(personDetailEntityBaseEntity -> {
                    DialogHelper.dismissProgressDialog();
                    activity.showPersonDetail(personDetailEntityBaseEntity.getData());
                }, throwable -> {
                    DialogHelper.dismissProgressDialog();
                    MLog.d(AppConstant.API_LOG, throwable.getMessage());
                });

        repertory.getPackersSkillsEntity(id)
                .subscribe(packersSkillsEntityBaseEntity -> {
                    DialogHelper.dismissProgressDialog();
                    activity.showPersonSkillsDetail(packersSkillsEntityBaseEntity.getData());
                }, throwable -> {
                    DialogHelper.dismissProgressDialog();
                    MLog.d(AppConstant.API_LOG, throwable.getMessage());
                });
    }

}
